
var e = getApp();

Component({
    properties: {
      isback: {
        value: true,
        type: Boolean
      },
      title: {
        value: "",
        type: String
      }
    },
    
    data: {
      statusBarHeight: 0, // 状态栏高度
      navBarHeight: 0, // 导航栏高度
      navStatusBarHeight: 0, // 导航栏和状态栏高度
      menu: 0, // 胶囊
    },
    ready: function() {
      this.getSystemInfo()
    },
    methods: {
      goback(){
        wx.navigateBack({
          delta: 1
        })
      },
      getSystemInfo() {
        let _this = this;
        // 获取手机系统信息
        wx.getSystemInfo({
          success: res => {
            // 手机系统状态栏高度
            //   wx.setStorageSync('statusBarHeight', res.statusBarHeight)
            _this.setData({
              statusBarHeight: res.statusBarHeight
            })
            const platform = res.platform
            const menu = wx.getMenuButtonBoundingClientRect()
            //menu为胶囊，判断是否能读到胶囊位置，读不到则用具体一般数值表示
            if (menu) {
              _this.setData({
                menu: menu,
                navBarHeight: menu.height + (menu.top - res.statusBarHeight) * 2,
                navStatusBarHeight: res.statusBarHeight + menu.height + (menu.top - res.statusBarHeight) * 2
              })
              _this.menu = menu
    
              // 导航栏高度
              _this.navBarHeight = menu.height + (menu.top - res.statusBarHeight) * 2
              // 状态栏加导航栏
    
              _this.navStatusBarHeight = res.statusBarHeight + menu.height + (menu.top - res.statusBarHeight) * 2
    
            } else {
              _this.setData({
                menu: null,
                navBarHeight: platform === 'android' ? 48 : 44,
                navStatusBarHeight: res.statusBarHeight + (platform === 'android' ? 48 : 44)
              })
              _this.menu = null
              _this.navBarHeight = platform === 'android' ? 48 : 44
              // 状态栏加导航栏
    
              _this.navStatusBarHeight = res.statusBarHeight + (platform === 'android' ? 48 : 44)
            }
          },
          fail(err) {
            console.log(err);
          }
        })
      },
      popupSpecsbtn: function(t) {
        console.log(t);
        this.triggerEvent("closeShow");
        this.setData({
            show: false
        });
    },
    }
});